// Covid-19 Vaccine Spillover onto General Vaccine Attitudes
/// Analysis of returning respondents for flu shot
/// use "waves789_and_202122_repeatrespondents.dta"
/// Table S1 and Figure S7


////////////////////////////// DATA CLEANING - data already has these variables - code kept to show coding process 
//gen  pid7x = . if party7x == 0
//replace pid7x = (-party7x + 7)/6

//gen pid7y = party7y
//gen party7oldy = party7y
//replace pid7y = . if party7oldy == 0
//replace pid7y = (-party7oldy + 7)/6

//replace vaxhesx = vaxhesx/12
//replace vaxhesy = vaxhesy/12
//replace eduy = (eduy-1)/6
//replace edux = (edux-1)/6
//replace cov_vacx = (cov_vacx-1)/4
//replace cov_vacy = (cov_vacy-1)/4

//gen femalex = .
//replace femalex = 1 if genderx == 112
//replace femalex = 0 if genderx == 111

//gen blackx = 0 if racex != 112
//replace blackx = 1 if racex == 111
//gen hispx = 0 if racex != 113
//replace hispx = 1 if racex == 113
//gen whitex = 0 if racex != 111
//replace whitex = 1 if racex == 111

//gen incx = (incomex-1)/9
//gen ideox = (ideologyx-1)/6

//gen vaxheschange = vaxhesy-vaxhesx
//gen pidchange = pid7y-pid7x
//gen cov_vacchange = cov_vacy-cov_vacx 

//gen cov_vacx_3 = .
//replace cov_vacx_3 = 0 if cov_vacx < .5
//replace cov_vacx_3 = 2 if cov_vacx > .5
//replace cov_vacx_3 = 1 if cov_vacx == .5


		
////////////// ANALYSES ////////////////////////////////////////////
	
	
/// Table S1 and Figure S7

logit flushotgoty flushotgotx pid7x covcon [pweight=weightnatx], or cluster(psid)
est store a0x
logit flushotgoty flushotgotx pid7x i.femalex i.blackx i.hispx agex eduy covcon incx [pweight=weightnatx], or cluster(psid)
est store a1x
logit flushotgoty flushotgotx c.pid7x##c.covcon i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx], or cluster(psid)
est store a1xi
margins, at(covcon = (0 1) pid7x=(0 1))
// Figure S7:
marginsplot, scheme(s1mono)

reg pidchange flushotgotx i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx],  cluster(psid)
est store a2x
reg covcon flushotgotx pid7x i.femalex i.blackx i.hispx agex eduy incx [pweight=weightnatx],  cluster(psid)
est store a3x

esttab a0x a1x a1xi a2x a3x using spilltableS1.rtf, eform ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(N)
		
		

			
	
















